home *** CD-ROM | disk | FTP | other *** search
/ Download Now 8 / Download Now V8.iso / Program / InternetTools / ApacheWebServer1.3.6 / apache_1_3_6_win32.exe / _SETUP.1 / MakeModuleMak.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1997-07-17  |  1.0 KB  |  60 lines

  1. #include <fstream.h>
  2. #include <assert.h>
  3. #include <stdio.h>
  4. #include <string.h>
  5. #include <stdlib.h>
  6.  
  7. void MakeMake(const char *szModule,const char *szSource)
  8.     {
  9.     ifstream ifs("Module.mak.tmpl",ios::nocreate);
  10.     assert(ifs.good());
  11.     
  12.     char buf[1024];
  13.     sprintf(buf,"%s.mak",szModule);
  14.     ofstream ofs(buf,ios::trunc);
  15.     for( ; ; )
  16.     {
  17.     ifs.getline(buf,sizeof buf);
  18.     if(ifs.eof())
  19.         break;
  20.     for(char *s=buf ; *s ; )
  21.         {
  22.         char *p=strchr(s,'%');
  23.         if(!p)
  24.         {
  25.         ofs << s << '\n';
  26.         break;
  27.         }
  28.         if(!strncmp(p,"%Module%",8))
  29.         {
  30.         ofs.write(s,p-s);
  31.         ofs << szModule;
  32.         s=p+8;
  33.         }
  34.         else if(!strncmp(p,"%Source%",8))
  35.         {
  36.         ofs.write(s,p-s);
  37.         ofs << szSource;
  38.         s=p+8;
  39.         }
  40.         else
  41.         {
  42.         ofs.write(s,p-s+1);
  43.         s=p+1;
  44.         }
  45.         }
  46.     }
  47.     }
  48.  
  49. void main(int argc,char **argv)
  50.     {
  51.     if(argc < 2 || (argc%2) != 1)
  52.     {
  53.     cerr << argv[0] << " [<module name> <source file>]+\n";
  54.     exit(1);
  55.     }
  56.     for(int n=1 ; n < argc ; n+=2)
  57.     MakeMake(argv[n],argv[n+1]);
  58.     }
  59.  
  60.